//
//	ZcoModelCcsMessage.m
//	Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport



#import "ZcoModelCcsMessage.h"

NSString *const kZcoModelCcsMessageData = @"data";
NSString *const kZcoModelCcsMessageFrom = @"from";
NSString *const kZcoModelCcsMessageIdField = @"id";
NSString *const kZcoModelCcsMessageTo = @"to";
NSString *const kZcoModelCcsMessageType = @"type";
NSString *const kZcoModelCcsMessageFromUser = @"fromUser";

@interface ZcoModelCcsMessage<T> ()
@property(strong , nonatomic) T t;
@end
@implementation ZcoModelCcsMessage




/**
 * Instantiate the instance using the passed dictionary values to set the properties values
 */

-(instancetype)initWithDictionary:(NSDictionary *)dictionary
{
	self = [super init];
	if(![dictionary[kZcoModelCcsMessageData] isKindOfClass:[NSNull class]]){
        self.data = dictionary[kZcoModelCcsMessageData];
	}

	if(![dictionary[kZcoModelCcsMessageFrom] isKindOfClass:[NSNull class]]){
		self.from = dictionary[kZcoModelCcsMessageFrom];
	}	
	if(![dictionary[kZcoModelCcsMessageIdField] isKindOfClass:[NSNull class]]){
		self.idField = dictionary[kZcoModelCcsMessageIdField];
	}	
	if(![dictionary[kZcoModelCcsMessageTo] isKindOfClass:[NSNull class]]){
		self.to = dictionary[kZcoModelCcsMessageTo];
	}	
	if(![dictionary[kZcoModelCcsMessageType] isKindOfClass:[NSNull class]]){
		self.type = dictionary[kZcoModelCcsMessageType];
	}
    if (![dictionary[kZcoModelCcsMessageFromUser] isKindOfClass:[NSNull class]]) {
        self.fromUser = [[ZcoModelUser alloc] initWithDictionary:dictionary[kZcoModelCcsMessageFromUser]];
    }
	return self;
}


/**
 * Returns all the available property values in the form of NSDictionary object where the key is the approperiate json key and the value is the value of the corresponding property
 */
-(NSDictionary *)toDictionary
{
	NSMutableDictionary * dictionary = [NSMutableDictionary dictionary];
	if(self.data != nil){
        if ([self.data respondsToSelector:@selector(toDictionary)]) {
            dictionary[kZcoModelCcsMessageData] = [self.data performSelector:@selector(toDictionary)];
        }else{
            dictionary[kZcoModelCcsMessageData] = self.data;
        }
	}
    if (self.fromUser != nil) {
        if ([self.fromUser respondsToSelector:@selector(toDictionary)]) {
            dictionary[kZcoModelCcsMessageFromUser] = [self.fromUser performSelector:@selector(toDictionary)];
        }else{
            dictionary[kZcoModelCcsMessageFromUser] = self.fromUser;
        }
    }
	if(self.from != nil){
		dictionary[kZcoModelCcsMessageFrom] = self.from;
	}
	if(self.idField != nil){
		dictionary[kZcoModelCcsMessageIdField] = self.idField;
	}
	if(self.to != nil){
		dictionary[kZcoModelCcsMessageTo] = self.to;
	}
	if(self.type != nil){
		dictionary[kZcoModelCcsMessageType] = self.type;
	}
	return dictionary;

}

/**
 * Implementation of NSCoding encoding method
 */
/**
 * Returns all the available property values in the form of NSDictionary object where the key is the approperiate json key and the value is the value of the corresponding property
 */
- (void)encodeWithCoder:(NSCoder *)aCoder
{
	if(self.data != nil){
		[aCoder encodeObject:self.data forKey:kZcoModelCcsMessageData];
	}
    if(self.fromUser != nil){
        [aCoder encodeObject:self.fromUser forKey:kZcoModelCcsMessageFromUser];
    }
	if(self.from != nil){
		[aCoder encodeObject:self.from forKey:kZcoModelCcsMessageFrom];
	}
	if(self.idField != nil){
		[aCoder encodeObject:self.idField forKey:kZcoModelCcsMessageIdField];
	}
	if(self.to != nil){
		[aCoder encodeObject:self.to forKey:kZcoModelCcsMessageTo];
	}
	if(self.type != nil){
		[aCoder encodeObject:self.type forKey:kZcoModelCcsMessageType];
	}

}

/**
 * Implementation of NSCoding initWithCoder: method
 */
- (instancetype)initWithCoder:(NSCoder *)aDecoder
{
	self = [super init];
	self.data = [aDecoder decodeObjectForKey:kZcoModelCcsMessageData];
    self.fromUser = [aDecoder decodeObjectForKey:kZcoModelCcsMessageFromUser];
	self.from = [aDecoder decodeObjectForKey:kZcoModelCcsMessageFrom];
	self.idField = [aDecoder decodeObjectForKey:kZcoModelCcsMessageIdField];
	self.to = [aDecoder decodeObjectForKey:kZcoModelCcsMessageTo];
	self.type = [aDecoder decodeObjectForKey:kZcoModelCcsMessageType];
	return self;

}

/**
 * Implementation of NSCopying copyWithZone: method
 */
- (instancetype)copyWithZone:(NSZone *)zone
{
	ZcoModelCcsMessage *copy = [ZcoModelCcsMessage new];
    copy.fromUser = [self.fromUser copy];
	copy.data = [self.data copy];
	copy.from = [self.from copy];
	copy.idField = [self.idField copy];
	copy.to = [self.to copy];
	copy.type = [self.type copy];

	return copy;
}
@end
